/*用户管理文件接口 */
import request from '@/utils/request.js'
import {
  DelUserResponseData,
  SaveUserResponseData,
  UpdataUserResponseData,
  User,
  UserListResponseData,
  HasAdminResponseData,
  roleVo,
  SaveAdminRolesResponseData,
  SelectIdDelUserResponseData
} from './type.js'
enum API {
  GetUserList_Url = '/admin/acl/user/',
  SaveUser_Url = '/admin/acl/user/save',
  UpdataUser_Url = '/admin/acl/user/update',
  DelUser_Url = '/admin/acl/user/remove/',
  HasAdminData_Url = '/admin/acl/user/toAssign/',
  SaveAdminRoles_URL = '/admin/acl/user/doAssignRole',
  SelectIdDelUser_URL = '/admin/acl/user/batchRemove'
}

export const reqUserList = (page: number, limit: number, username?: string) =>
  request.get<any, UserListResponseData>(
    API.GetUserList_Url + `${page}/${limit}?username=${username}`
  )
export const reqSaveUser = (UserParams: User) =>
  request.post<any, SaveUserResponseData>(API.SaveUser_Url, UserParams)
export const reqUpdataUser = (UserParams: User) =>
  request.put<any, UpdataUserResponseData>(API.UpdataUser_Url, UserParams)
export const reqDelUser = (id: number | string) =>
  request.delete<any, DelUserResponseData>(API.DelUser_Url + `${id}`)

export const reqHasAdminData = (adminId: number | string) =>
  request.get<any, HasAdminResponseData>(API.HasAdminData_Url + `${adminId}`)
export const reqSaveAdminRoles = (roleVo: roleVo) =>
  request.post<any, SaveAdminRolesResponseData>(API.SaveAdminRoles_URL, roleVo)
export const reqSelectIdDelUser = (idList: number[]) =>
  request.delete<any, SelectIdDelUserResponseData>(API.SelectIdDelUser_URL, { data: idList })
